
////思路：需要注意的是从当前字符搭配下一个字符顺时针转还是逆时针转，需要判断两个方向的距离并取小值

/**
 * @param {string} word
 * @return {number}
 */
var minTimeToType = function(word) {
    if (word.length === 1) return 1;
    let prePos = 0, res = 0;
    for(let i = 0; i < word.length; i++) {
        let curPos = word.charCodeAt(i) - 97;
        console.log(curPos);
        let offset = Math.abs(curPos - prePos)
        res += (1 + Math.min(offset, 26 - offset));
        
        prePos = curPos;
    }
    return res;
};
console.log(minTimeToType("zjpc"));